<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>滚屏管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		$(document).ready(function() {
			$("#title").focus();
			$("#inputForm").validate({
				submitHandler: function(form){
					if($("#logoUrl").val()==""){
						showJBoxMess("请上传滚屏图片.","error");
						return;
					}
					loading('正在提交，请稍等...');
					form.submit();
				},
				errorContainer: "#messageBox",
				errorPlacement: function(error, element) {
					$("#messageBox").text("输入有误，请先更正。");
					if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
						error.appendTo(element.parent().parent());
					} else {
						error.insertAfter(element);
					}
				}
			});
		});
		
		function showPhoto(path){
			$("#logoUrl").val(path);
			$("#cutPhoto").css("display", "block");
			var imageSrc = '${ctx}/download?filePath='+path;
			$("#cutPhoto").attr("src", imageSrc);
		}
	</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<li><a href="${ctx}/ivm/business/rollscreen/list">滚屏列表</a></li>
		<li class="active"><a href="${ctx}/ivm/business/rollscreen/form?id=${rollScreen.id}">滚屏<shiro:hasPermission name="ivm:business:rollscreen:edit">${not empty rollScreen.id?'修改':'添加'}</shiro:hasPermission><shiro:lacksPermission name="ivm:business:rollscreen:edit">查看</shiro:lacksPermission></a></li>
	</ul><br/>
	<form:form id="inputForm" modelAttribute="rollScreen" action="${ctx}/ivm/business/rollscreen/save" method="post" class="form-horizontal">
		<form:hidden path="id"/>
		<form:hidden path="merchant.id"/>
		<tags:message content="${message}"/>
		<div class="control-group">
			<label class="control-label"><span class="color-red font-size20">*</span>标题:</label>
			<div class="controls">
				<form:input path="title" htmlEscape="false" maxlength="200" class="required"/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label"><span class="color-red font-size20">*</span>滚屏图片:</label>
			<div class="controls">
				<form:hidden path="logoUrl" />
				<div class="photo" style="width:149px; height:84px;">
					<c:if test="${rollScreen.logoUrl!=null && rollScreen.logoUrl!=''}">
						<img id="cutPhoto" src="${ctx}/download?filePath=${rollScreen.logoUrl }" style="width:149px; height:84px;" />
					</c:if>
					<c:if test="${rollScreen.logoUrl==null || rollScreen.logoUrl==''}">
						<img id="cutPhoto" src="" style="width:149px; height:84px;" />
					</c:if>
				</div>
				<a href="javascript:" class="btn" id="cutPhotoUpload">上传图片</a>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label"><span class="color-red font-size20">*</span>链接地址:</label>
			<div class="controls">
				<form:input path="webUrl" htmlEscape="false" maxlength="200" class="required"/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label"><span class="color-red font-size20">*</span>状态:</label>
			<div class="controls">
				<form:radiobuttons path="status" items="${fns:getDictList('roll_status')}" itemLabel="label" itemValue="value" htmlEscape="false" class="required" />
			</div>
		</div>
		<div class="control-group">
			<label class="control-label"><span class="color-red font-size20">*</span>排序:</label>
			<div class="controls">
				<form:input path="sort" htmlEscape="false" maxlength="50" class="required digits"/>
			</div>
		</div>
		<div class="form-actions">
			<shiro:hasPermission name="ivm:business:rollscreen:edit"><input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存"/>&nbsp;</shiro:hasPermission>
			<input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)"/>
		</div>
	</form:form>
</body>
</html>
